package com.javatom.notes.seata.xa.account;

import com.javatom.notes.seata.xa.account.pojo.AccountPojo;
import com.javatom.notes.seata.xa.account.service.AccountService;
import com.javatom.notes.seata.xa.account.service.OrderService;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @description:
 * @author: 曾维录
 * @time: 2019/8/19 18:05
 */
@Component
@Slf4j
@Configuration
public class AppRun implements ApplicationRunner {
    @Resource
    private AccountService accountService;
    @Resource
    private OrderService orderService;
    @Override
    public void run(ApplicationArguments args) throws Exception {
       // test();
    }
    @GlobalTransactional(name = "javatom-test",rollbackFor = Exception.class)
   public void  test(){
        AccountPojo a = new AccountPojo();
        a.setAccount("11t11");
        a.setMoney(22);
       accountService.insert(a);
       orderService.insert(222,3);
//       log.error("{}",1/0);
   }
}
